﻿using System.ComponentModel;
using System.Windows;

namespace Demos.GasStations
{
    public abstract class ElementoVisual : DependencyObject
    {
        public double X
        {
            get { return (double)GetValue(XProperty); }
            set { SetValue(XProperty, value); }
        }

        // Using a DependencyProperty as the backing store for X.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty XProperty =
            DependencyProperty.Register("X", typeof(double), typeof(ElementoVisual), new UIPropertyMetadata(null));


        public double Y
        {
            get { return (double)GetValue(YProperty); }
            set { SetValue(YProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Y.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty YProperty =
            DependencyProperty.Register("Y", typeof(double), typeof(ElementoVisual), new UIPropertyMetadata(null));
    }

    public class Coche : ElementoVisual,INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    
        private int _capacidad;
        public int Capacidad
        {
            get { return _capacidad; }
            set
            {
                _capacidad = value;
                NotifyPropertyChanged("Capacidad");
            }
        }

        public Coche(double x, double y, int capacidad)
        {
            X = x;
            Y = y;
            Capacidad = capacidad;
        }
    }

    public class Estacion : ElementoVisual
    {
        public double Distancia { get; set; }

        public Estacion(double x, double y, double distancia)
        {
            X = x;
            Y = y;
            Distancia = distancia;
        }
    }

    public class Carretera : ElementoVisual
    {
        public double Longitud { get; set; }
        public double X1 { get; set; }
        public double Y1 { get; set; }
        public double X2 { get; set; }
        public double Y2 { get; set; }

        public Carretera(double x1, double y1, double x2, double y2, double x, double y, double longitud)
        {
            X1 = x1;
            X2 = x2;
            Y1 = y1;
            Y2 = y2;
            X = x;
            Y = y;
            Longitud = longitud;
        }
    }
}
